package com.nagat.ejb.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;


@Entity
@Table(name="orders")
public class Order implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Integer orderid;
	
	private Float amount;
	
	
	private Set<OrderItem> orderitems = new HashSet<OrderItem>();
	
	
	private Date createdate;

	@Id
	@GeneratedValue
	public Integer getOrderid() {
		return orderid;
	}

	public void setOrderid(Integer orderid) {
		this.orderid = orderid;
	}

	public Float getAmount() {
		return amount;
	}

	public void setAmount(Float amount) {
		this.amount = amount;
	}
	
	@OneToMany(mappedBy="order",cascade=CascadeType.ALL,fetch=FetchType.LAZY)
	@OrderBy(value = "id ASC")
	public Set<OrderItem> getOrderitems() {
		return orderitems;
	}


	public void setOrderitems(Set<OrderItem> orderitems) {
		this.orderitems = orderitems;
	}

	public Date getCreatedate() {
		return createdate;
	}
	@Temporal(TemporalType.TIMESTAMP)
	public void setCreatedate(Date createdate) {
		this.createdate = createdate;
	}

}
